package algorithm;

public abstract class AlgorithmStrategy {
	private String methodName;
	private String filePath;
	private ValueFactory[] factories;
	protected MParameter[] paraList;
	protected int tcNum = 1;

	/**
	 * For this version, we produce a list of one parameter together, and return
	 * a list of result
	 * 
	 * @param paraList
	 *            : parameter list
	 * @return result[]
	 */
	public AlgorithmStrategy(String filePath, String method, int tcNum,
			MParameter[] paraList) {
		this.methodName = method;
		this.filePath = filePath;
		this.paraList = paraList;
		this.tcNum = tcNum;
		
	}

	public Object[] getMethodResult() {
		return getResult();
	}

	/**
	 * The most important method, to get the test method,
	 * @param paraList
	 */
	private Object initMethod(Object[] para) {
		return null;
	}
/**
 * call the 
 * @return
 */
	private Object[][] getValueFromFactory() {
		Object[][] value = new Object[tcNum][paraList.length];
		for (int i = 0; i < factories.length; i++) {
			MParameter tmp = paraList[i];
			value[i] = factories[i].getValue(tmp.getMin(), tmp.getMax());
		}
		return value;
	}

	/**
	 * Run the method tcNum times
	 * 
	 * @return
	 */
	private Object[] getResult() {
		Object[] result = new Object[tcNum];
		Object[][] value = getValueFromFactory();
		for (int i = 0; i < tcNum; i++) {
			result[i] = initMethod(value[i]);
		}
		return result;
	}
	/**
	 * init ValueFactoryInterface[] factories;
	 */
	protected abstract void initFactory();

	public abstract Object[][] getValues();

}
